$(function(){
	//加载我得列表
	loadMyPrescription();
	mui.previewImage();
});

function loadMyPrescription(){
	var param= {"patientid": USERID};
	prescriptionModule.queryMyPrescription(param,showPrescription)
}
function showPrescription(data){
	console.log(data)
		 var showhtml="";
		 var json =data; 
		 for(var i=0;i<json.length;i++){
			var item=json[i];
			showhtml+='<div class="prescription-sheetBox">';
			showhtml+='<div class="title">我的处方单 <span class="diagnosis">'+item.diagnosis+'</span></div>';
			showhtml+='<div class="main font">';
			showhtml+='<table cellpadding="0" cellspacing="0">';
			showhtml+=	'<thead><tr><td>药品</td><td style="width: 1rem;">数量</td><td style="width: 1rem;">用量</td><td style="width: 1rem;">频次</td></tr></thead>';
			showhtml+=	'<tbody>';
			for(var j=0;j<item.prescriptionDetailList.length;j++){
				var list=item.prescriptionDetailList[j];
				showhtml+='<tr><td>'+list.name+'</td>';
				showhtml+='<td>'+list.count+'盒</td>';
				if(list.usagemethod!=""){
					var strs=list.usagemethod.split("-"); //字符分割
					showhtml+='<td>'+strs[1]+'</td>';
					showhtml+='<td>'+strs[0]+'</td>';
				}else{
					showhtml+='<td>每次500g</td>';
					showhtml+='<td>一日三次</td>';
				}
				showhtml+='</tr>';
			}
			showhtml+='</tbody></table>';
			var $told = item.told;
				if(utilModule.checkUndefined($told)!="") {
					showhtml+='<div class="entrust">医生嘱托: '+item.told+'</div>';
				} 
			showhtml+='<div class="time">';
			showhtml+=	item.createtime;
			showhtml+='<span><img src="'+item.autograph+'"    data-preview-src=""   data-preview-group="1"  style="width: 1.5rem;" /></span>';
			showhtml+='<span> 医师签名:</span> ';
			showhtml+='<font></font>';
			showhtml+='</span></div></div></div>';
			showhtml+='<div class="prescription-sheetOperation">';
			
			/*showhtml+='<button class="delete"  disabled="disabled" style="display: none;">删除处方</button>';*/
			/*item.isbuy==1;*/
			if(item.isbuy!=1){
				showhtml+='<button class="adress" href="../prescription/prescription-wechat.html?orderid='+item.id+'">一键寻药</button></div>';
			}
		}
		 if(json.length==0 || json.result!=undefined){
			 showhtml='<div class="prescription-consultationBox"><div><img src="../../images/cf1_03.png" /><p class="font5">还没有医生为您添加处方单</p></div></div>';
		 }
		 $("#prescription-content").html(showhtml);
		 $(".adress").on('click',function(){
	   		location.href = $(this).attr("href");
	   	});
}